﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;


namespace Xperf123
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();

        }

        public string _Pid = "";
        public string MaxValue
        {
            get { return _Pid; }
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            //foreach (System.Diagnostics.Process winProc in System.Diagnostics.Process.GetProcesses())
            //{
            //    MessageBox.Show("Process " + winProc.Id + ": " + winProc.ProcessName);
            //}

            this.Text = "Select Process to monitor";



            int count = 0;
            //  label2.Text = "Total = ";
            Process[] prs = Process.GetProcesses();
            listBox1.Items.Clear();
            foreach (Process proces in prs)
            {
                count++;
                listBox1.Items.Add(proces.ProcessName);
                listBox2.Items.Add(proces.Id);
            }
            label2.Text += count.ToString();


            //}
        }


     
        private void button2_Click(object sender, EventArgs e)
        {

            _Pid = textBox1.Text;
   
            this.Hide();


        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int p = listBox1.SelectedIndex;
            listBox2.SelectedIndex = p;
            textBox1.Text = listBox2.Text.ToString();

        }



    }
}
